<!DOCTYPE html>
<html>
<body>

<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>

<div id="main">main
  <div role="checkbox" id="checkbox">checkbox</div>
</div>

<script>
test(function() {
    var main = document.getElementById("main");
    var checkbox = document.getElementById("checkbox");

    var button_accNode = new AccessibleNode();
    button_accNode.role = "button";

    main.accessibleNode.appendChild(button_accNode);

    var axMain = accessibilityController.accessibleElementById("main");
    var axButton = axMain.childAtIndex(0);

    // Remove checkbox will cause ChildrenChanged called on axMain, which will
    // remove all its children in the AXObjectCache.
    checkbox.remove();

    // Try to fetch axButton, since its detached from its parent axMain, we need
    // to recompute its parent. Make sure no DCHECK or crash occurs.
    axButton = axMain.childAtIndex(0);
});
</script>

</body>
</html>
